package com.yh.tea.controller;


import com.yh.tea.entity.ArticleType;
import com.yh.tea.model.ArticleTypeQuery;
import com.yh.tea.service.ArticleTypeService;
import com.yh.tea.utiity.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yh
 * @since 2024-04-08
 */
@RestController
@RequestMapping("/articleType")
public class ArticleTypeController {
    @Autowired
    private ArticleTypeService articleTypeService;

    @PostMapping("/add")
    public ResponseResult add(@RequestBody ArticleType articleType){
        Boolean result=articleTypeService.save(articleType);
        return ResponseResult.success(result?"添加成功":"添加失败",result);
    }

    @PostMapping("/del")
    public ResponseResult del(@RequestBody List<Long> ids){
        Boolean result=articleTypeService.removeByIds(ids);
        return ResponseResult.success(result?"删除成功":"删除失败",result);
    }

    @PostMapping("/getPage")
    public ResponseResult getPage(@RequestBody ArticleTypeQuery query){
        return articleTypeService.getPage(query);
    }


}

